home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
pdox35sc.zip
/
BACKUP.SC
next >
Wrap
Text File
|
1991-06-10
|
26KB
|
356 lines
; ***************************************************************************************
; BACKING UP DATA TO A FLOPPY DISK
; Copyright 1991 Virginia B. Sauer All Rights Reserved
; This program may be copied/modified without charge provided both that this
; copyright notice is included without change, and that any accompanying
; documentation includes the notice "Portions of code (c) Copyright 1991,
; Virginia B. Sauer"
; ***************************************************************************************
; Failure to back up data has caused countless corporations to lose critical information.
; In many instances, the problem is that of ignorance: novices forget the necessary
; commands, and are either too busy or too embarrassed to request assistance.
; To forestall such problems, the following utility has been developed to walk the user
; through automatically formatting a floppy disk and/or copying the respective files to
; the diskette.
; As this is completely generic, it can effortlessly be incorporated into any application
; you design.
; ───────────────────────────────────────────────────────────────────────────────────────
; *************** I M P O R T A N T N O T E ***************
; To invoke this procedure, you will also need to create a file named Backup.Txt,
; comprised of three lines of code:
; (one blank line)
; N (the letter N)
; ^Z (Ascii character 26)
; (This is to ensure a complete user-friendly, menu-driven application by bypassing DOS
; questions when the diskette is being formatted.)
; ───────────────────────────────────────────────────────────────────────────────────────
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ PARAMETERS PASSED TO THIS PROCEDURE ║
; ╟──────────┬───────────────────────────────────────────────────────┬───────────────────╢
; ║ ARGUMENT │ DESCRIPTION │ SAMPLE ║
; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
; ║ │ 1 - 14 character name/abbreviation of your │ ║
; ║ │ application (e. g., "Testing", to signify a │ "Testing" ║
; ║SystemName│ system named Testing) │ ║
; ║ │ │ (To signify a ║
; ║ │ N. B. Unless this is a variable, it must be │ testing system) ║
; ║ │ enclosed in quotes. │ ║
; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
; ║ │ The files to be copied ... e. g., "ALL", to copy │ ║
; ║ │ all files in the specified directory, or "AR", to │ "ALL" ║
; ║ │ copy only those with the prefix "AR" (for Archive) │ ║
; ║ │ │ ║
; ║WhichFiles│ Obviously, this segment of code can be modified │ (To copy all ║
; ║ │ to reflect your own naming conventions. │ files in the ║
; ║ │ │ specified ║
; ║ │ N. B. Unless this is a variable, it must be │ directory) ║
; ║ │ enclosed in quotes. │ ║
; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
; ║ │ │ "C:\\TPTS\\DATA" ║
; ║ │ The full path of the directory containing the files │ ║
; ║ │ to be copied (using double backslashes to separate │ (To signify ║
; ║ │ drive, directory, and subdirectory) - e. g., │ Drive C, Direc- ║
; ║ │ "C:\\TPTS\\Data" if the files are located in Drive │ tory TPTS, Sub- ║
; ║ │ C, Directory TPTS, SubDirectory Data │ Directory Data) ║
; ║ │ │ ║
; ║ │ Should you prefer to default to the user's current │ -or- ║
; ║ WhichDir │ directory, either eliminate this argument, or sub- │ ║
; ║ │ stitute a variable for the directory path (e. g., │ CurrDir ║
; ║ │ CurrDir, for Current Directory) and declare the │ ║
; ║ │ variable before invoking the procedure: │ (to signify var- ║
; ║ │ CurrDir = Directory() │ iable CurrDir, ║
; ║ │ │ which must then ║
; ║ │ N. B. Unless this is a variable, it must be │ be declared be- ║
; ║ │ enclosed in quotes. │ fore calling the ║
; ║ │ │ procedure) ║
; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
; ║ │ The type of PC being used ("AT", "XT", "386", or │ ║
; ║ │ "Laptop") │ ║
; ║ │ │ ║
; ║ │ Unfortunately, many clones fail to specify class - │ "AT" ║
; ║ │ and most beginners have no idea what they are │ ║
; ║ PCType │ using. When in doubt, it is therefore prudent to │ ║
; ║ │ have applications default to "XT", since double │ (to specify ║
; ║ │ density diskettes can also be used by ATs. │ an AT) ║
; ║ │ │ ║
; ║ │ N. B. Unless this is a variable, it must be │ ║
; ║ │ enclosed in quotes. │ ║
; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
; ║ │ The drive in which the diskette is to be placed │ ║
; ║ │ (e. g., "A", to signify drive A) │ "A" ║
; ║ WhereTo │ │ ║
; ║ │ N. B. Unless this is a variable, it must be │ (to signify) ║
; ║ │ enclosed in quotes. │ Drive A) ║
; ╚══════════╧═══════════════════════════════════════════════════════╧═══════════════════╝
;----------Check whether or not the specified drive is ready
Proc Check_TargetDrive() ;---Check whether or not the specified drive is ready
Private Keypressed
Cursor off
Clear Clearall
Paintcanvas Attribute 00 00, 00, 24, 79 Style attribute 15 ; black
If not Drivestatus(Whereto) ; Apprise user if drive is not ready
Then Paintcanvas Attribute 63 03, 11, 21, 64 Style Attribute 63 ; White on cyan
@ 03,11 ?? Fill("\223",53) ; Use Ascii
@ 21,11 ?? Fill("\220",53) ; characters
For X From 2 TO 20 ; to create frame:
@ (X+1), 11 ?? "\219" ; 223 ▀
@ (X+1), 64 ?? "\219" ; 219 █
EndFor ; 220 ▄
@ 11,15 ?? "Please make sure that the diskette is placed"
@ 12,15 ?? "in your computer's floppy drive " + Upper(Whereto) + ". Pull"
@ 13,15 ?? "down the lever at the top of the floppy"
@ 14,15 ?? "drive (or, if there is no lever, make"
@ 15,15 ?? "certain the diskette is firmly in place)."
Style Attribute 15 ; white on black
@ 6,20 ?? "\219", Fill("\223",36), "\219" ; Use Ascii characters to
@ 7,20 ?? "\219", Fill(" ",36), "\219" ; create box:
@ 8,20 ?? "\219", Fill("\220",36), "\219" ; 223 = ▀, 219 = █, 220 = ▄
Style attribute 03
@ 18,26 ?? "Press any key when ready."
Style attribute 139 ; blinking text
@ 07,27 ?? "DRIVE " + Upper(Whereto) + " IS NOT READY !!!"
Keypressed = Getchar()
Endif
Endproc
Proc Backup_Data(SystemName,WhichFiles,WhichDir,PCType,WhereTo)
Private Density, ; Density of diskette (determined by argument PCType)
Header, ; Heading (determined by argument SystemName)
YN ; Whether or not user wants diskette formatted
;--------------------------------------------------------------------------------------
; Determine disk size and density (to instruct user what is needed for his PC)
;--------------------------------------------------------------------------------------
Switch
Case Upper(PCType) = "AT"
or Upper(PCType) = "386" : Disksize = "5 1/4"
Density = "high"
Case Upper(PCType) = "XT" : Disksize = "5 1/4"
Density = "double"
Case Upper(PCType) = "LAPTOP" : Disksize = "3 1/2"
Density = "double"
Endswitch
;--------------------------------------------------------------------------------------
; Draw frame
;--------------------------------------------------------------------------------------
Clear Clearall
Paintcanvas Attribute 00 00, 00, 24, 79 Style Attribute 15 ; Draw black canvas
Paintcanvas Attribute 63 01, 03, 24, 75 ; white on cyan
@ 00,03 ?? Fill("\220",74) ; Use Ascii
@ 24,03 ?? Fill("\223",74) ; characters
For X From 0 TO 22 ; to create frame:
@ (X+1), 03 ?? "\219" ; 223 ▀
@ (X+1), 76 ?? "\219" ; 219 █
EndFor ; 220 ▄
;--------------------------------------------------------------------------------------
; Provide step-by-step instructions (based on user's type of PC, et cetera)
;--------------------------------------------------------------------------------------
Style Attribute 48 ; black on cyan
@ 7,10 ?? "You will need a formatted "+DiskSize+"-inch double-sided, "+Density+"-"
@ 8,10 ?? "density diskette (floppy disk)."
@ 10,10 ?? "Holding the diskette at the top (so that the manufacturer's"
@ 11,10 ?? "label is to the right, and the write-protect notch is to the"
@ 12,10 ?? "left), place it in your computer's floppy drive "+ Upper(WhereTo) +"."
@ 14,10 ?? "Pull down the lever at the top of the floppy drive. (If"
@ 15,10 ?? "there is no lever, make certain that the diskette is firmly"
@ 16,10 ?? "in place.)"
;--------------------------------------------------------------------------------------
; Ask user whether or not the diskette must be formatted
;--------------------------------------------------------------------------------------
Style attribute 63 ; White on cyan
@ 18,21 ?? "Does this diskette need to be formatted?"
;--------------------------------------------------------------------------------------
; Center the heading within a small box at the top of the screen
; (Modify the spacing for Header if your system name exceeds 14 characters.)
;--------------------------------------------------------------------------------------
Style Attribute 15 ; white on black
@ 2,13 ?? "\219", Fill("\223",52), "\219" ; Use Ascii characters to
@ 3,13 ?? "\219", Fill(" ",52), "\219" ; create box:
@ 4,13 ?? "\219", Fill("\220",52), "\219" ; 223 = ▀, 219 = █, 220 = ▄
Style Attribute 11 ; light cyan on black
Header = "BACKING UP " + Upper(SystemName) + " SYSTEM RECORDS"
@ 3,16 ?? Format("AC,CU,W48",Strval(Header))
;--------------------------------------------------------------------------------------
; Instruct user to press enter key when finished, or escape key to quit
;--------------------------------------------------------------------------------------
Style Attribute 03 ; cyan on black
@ 22,14 ?? "Press the <Enter> key when finished (or <Esc> to quit)."
Style Attribute 15 ; white on black
@ 20,26 ?? "Please answer Yes or No: " ; relates to the above question
Style Attribute 11 Accept "A3" Required picture "{YES,NO}" to YN
;--------------------------------------------------------------------------------------
; Return if user pressed Escape key ... Otherwise, let him know when diskette is
; being formatted, et cetera
;--------------------------------------------------------------------------------------
If retval = False ; Return if user pressed escape key
Then return
;-----------------------------------------------------------------------------------
; If the diskette must be formatted, apprise user.
; Use Run NoRefresh commands to leave canvas in view while shelling to DOS.
; As explained above, to avoid confusing novices with DOS questions, create a
; file named Backup.Txt, consisting of three lines of code:
; (one blank line)
; N (the letter N)
; \26 (\26, to denote Ascii character 26)
; (<Backup.Txt then tells DOS to follow the directions in this file.)
; Add >Nul to instruct DOS not to confuse the user by displaying messages.
;-----------------------------------------------------------------------------------
Else Check_TargetDrive() ; ensure that target drive is ready
If YN = "YES"
Then Please_Wait("Please wait while the diskette is being formatted.")
Run NoRefresh "Format " + WhereTo + ": <Backup.Txt >Nul"
Endif
Please_Wait("Please wait until light goes out and you hear a beep")
;------------------------------------------------------------------------------
; Shell to DOS to copy the designated files to the diskette. (In this
; case, use Run Big in case many large files are involved.)
; If necessary, modify the following segment of code to reflect your own
; naming conventions - e. g., to copy a table named orders:
; Case Upper(WhichFiles) = "ORDERS" : WhichFiles = "ORDERS"
;------------------------------------------------------------------------------
If not Match(WhichDir,"..\\") ; Missing trailing
then WhichDir = WhichDir + "\\" ; Backslash
Endif
If Upper(Whichfiles) = "ALL" ; Establish which
Then WhichFiles = "" ; files are copied
Endif
WhichFiles = WhichDir + WhichFiles + "*.db "
Run Big NoRefresh "Copy " + WhichFiles ; Copy designated
+ WhereTo + ":>Nul" ; files to diskette
Endif
Beep ; Beep to advise user that backup is finished
Endproc
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ EXAMPLE(S) ║
; ║ ║
; ║ To be invoked AFTER creating a file named Backup.Txt consisting of three lines ║
; ║ of code: ║
; ║ (one blank line) ║
; ║ N (the letter N) ║
; ║ \26 (\26, to denote Ascii character 26) ║
; ║ ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (1) If copying all files of a system named "Testing" from subdirectory Data of ║
; ║ Directory TPTS (Drive C) of an AT to a floppy disk in drive A: ║
; ║ ║
; ║ Backup_Data("Testing","All","C:\\TPTS\\Data","AT","A") ║
; ║ ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (2) If copying all Purchasing System files with the prefix "AR" from the current ║
; ║ directory of an XT to a floppy disk in drive B: ║
; ║ ║
; ║ CurrDir = Directory() ║
; ║ ║
; ║ Backup_Data("Purchasing","AR",CurrDir,"XT","B") ║
; ║ ║
; ╚══════════════════════════════════════════════════════════════════════════════════════╝
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ VARIATION(S) ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (1) If the files are likely to outgrow one diskette, a compression utility ║
; ║ should be incorporated. ║
; ║ ║
; ║ Make certain that you obtain the proper licenses (e. g., for runtime ║
; ║ versions or systems to be distributed to other users). ║
; ║ ║
; ║ Replace "Run Big Copy..." with the respective commands for the archiving ║
; ║ utility you have selected - e. g., if using ARC: ║
; ║ Run Big NoRefresh "Arc A A:\\TestArch.Arc " + WhichFiles ║
; ║ + WhereTo + ":>Nul" ║
; ║ ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (2) When creating runtime applications, it is patently impossible to know the ║
; ║ hardware and software under which they will run. ║
; ║ ║
; ║ The system's main menu should therefore include a "change configurations" ║
; ║ option to enable users to designate their printers, type of PC, et cetera. ║
; ║ ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (3) Obviously, these procedures can be modified to accomodate tape backup ║
; ║ systems. As in the case of archive utilities, simply substitute the ║
; ║ appropriate commands, and modify the on-screen directives accordingly. ║
; ║ ║
; ╚══════════════════════════════════════════════════════════════════════════════════════╝
; ***************************************************************************************
; SHOW MESSAGE TO PREVENT IMPATIENT USERS FROM WREAKING HAVOC
; (A generic procedure utilized by backup procedure, but useful in any application.)
; ***************************************************************************************
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ PARAMETERS PASSED TO THIS PROCEDURE ║
; ╟──────────┬───────────────────────────────────────────────────────────────────────────╢
; ║ ARGUMENT │ DESCRIPTION ║
; ╟──────────┼───────────────────────────────────────────────────────────────────────────╢
; ║ │ ║
; ║ │ Message of up to 52 characters, apprising user that program is running, ║
; ║ │ and/or what is expected of him: ║
; ║ │ ║
; ║ │ e. g., "Please wait while the information is being processed" ║
; ║ │ ║
; ║ WaitMssg │ "Please wait until light goes out and you hear a beep" ║
; ║ │ ║
; ║ │ "Please wait while the records are being extracted" ║
; ║ │ ║
; ║ │ ║
; ║ │ N. B. Unless the message, itself, is a variable, this must be ║
; ║ │ enclosed in quotes. ║
; ║ │ ║
; ╚══════════╧═══════════════════════════════════════════════════════════════════════════╝
Proc Please_Wait(WaitMssg)
Cursor Off ; Do not show cursor
Clear Clearall ; Clear screen and canvas
PaintCanvas Attribute 00 00, 00, 24, 79 ; Draw black background
PaintCanvas Attribute 112 10, 07, 14, 75 ; Draw grey shadow
PaintCanvas Attribute 48 09, 04, 13, 73 ; Draw cyan box
Style Attribute 176 ; Draw blinking black characters
@ 11,05 ?? " \07 \07 \07 " ; (Ascii code 7)
@ 11,66 ?? " \07 \07 \07 " ; (Ascii code 7)
Style Attribute 48 ; Show black lettering
@ 11,13 ?? Format("AC,CC,W52",Strval(Waitmssg)) ; Center message (capitalizing
Endproc ; first letter of each word)
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ EXAMPLE ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ To show the message, "Please Wait While Information Is Being Computed": ║
; ║ Please_Wait("Please wait while information is being computed") ║
; ║ ║
; ║ (The procedure will automatically capitalize the first letter of each word. ║
; ║ Should you prefer to capitalize the entire message, replace "CC" with "CU" ║
; ║ in the format command.) ║
; ║ ║
; ╚══════════════════════════════════════════════════════════════════════════════════════╝